import { Controller, Get, Query } from '@nestjs/common';
import { OrderService } from './order.service';
import { Order } from '../entities/order.entity';

export interface FindAllResponse {
  data: Order[];
  total: number;
}

@Controller('orders')
export class OrderController {
  constructor(private readonly orderService: OrderService) {}

  @Get()
  findAll(
    @Query('name') name?: string,
    @Query('phone') phone?: string,
    @Query('orderNumber') orderNumber?: string,
    @Query('page') page?: number,
    @Query('size') size?: number,
  ): Promise<FindAllResponse> {
    return this.orderService.findAll({
      name,
      phone,
      orderNumber,
      page,
      size,
    });
  }
}
